package com.vancouver.knows.business.tracker;

import com.pangu.task.IResultReceiver;
import com.pangu.task.OperateResult;
import com.vancouver.knows.business.BusinessModule;
import com.vancouver.knows.business.Constants;
import com.vancouver.knows.business.bean.CityNewsDetailInfo;
import com.vancouver.knows.business.bean.CityNewsInfo;

/**
 * 获取城事详情
 * 
 * @author chenxunlin01
 * 
 */
public class FetchCityNewsDetailTracker extends ABInvokeTracker {

	public FetchCityNewsDetailTracker(BusinessModule module, IResultReceiver resultReceiver) {
		super(module, resultReceiver);
	}

	@Override
	public String TAG() {
		return FetchCityNewsDetailTracker.class.getSimpleName();
	}

	@Override
	public void handleResult(OperateResult result) {
		CityNewsDetailInfo cityNewsDetailInfo = (CityNewsDetailInfo) result.getResultData();
		if (cityNewsDetailInfo != null) {
			module.getCacheManager().getCityNewsDetailInfoMap().put(cityNewsDetailInfo.getId(), cityNewsDetailInfo);
			// 更新评论个数
			CityNewsInfo cityNewsInfo = module.getCacheManager().getCityNewsInfoCache()
					.getItemInfoById(cityNewsDetailInfo.getId());
			if (cityNewsInfo != null) {
				if (cityNewsInfo.getCommentCount() != cityNewsDetailInfo.getCommentCount()) {
					cityNewsInfo.setCommentCount(cityNewsDetailInfo.getCommentCount());
					imContext.handleMobEmptyMessage(Constants.BUSINESS_STATUS_CITYNEWS_COMMENT_COUNT_CHANGE);
				}
			}
		}
	}
}
